package com.coffee.cmt.test;

import org.apache.flink.streaming.api.functions.KeyedProcessFunction;
import org.apache.flink.util.Collector;

/**
 * @author songkui
 * @since 2024/6/20 10:16
 */
public class FraudDetector extends KeyedProcessFunction<String, AccountTransation, AccountTransation> {

    private static final long serialVersionUID = 1L;

    private static final double SMALL_AMOUNT = 1.00;
    private static final double LARGE_AMOUNT = 500.00;
    private static final long ONE_MINUTE = 60 * 1000;

    @Override
    public void processElement(
            AccountTransation transaction,
            Context context,
            Collector<AccountTransation> collector) throws Exception {

        // 不停的收集数据,即存在诈骗的交易账户
        if(transaction.getTransationMoney()>LARGE_AMOUNT) {
            collector.collect(transaction);
        }

    }

}
